package com.xdb.sqlparser.dialect.mysql.ast.statement;

import com.xdb.sqlparser.ast.SQLName;
import com.xdb.sqlparser.ast.statement.SQLAlterTableAddColumn;
import com.xdb.sqlparser.dialect.mysql.ast.MySqlObject;
import com.xdb.sqlparser.dialect.mysql.visitor.MySqlASTVisitor;
import com.xdb.sqlparser.visitor.SQLAstVisitor;

public class MySqlAlterTableAddColumn extends SQLAlterTableAddColumn implements MySqlObject {

	private SQLName firstColumn;
	private SQLName afterColumn;

	private boolean first;

	public SQLName getFirstColumn() {
		return firstColumn;
	}

	public void setFirstColumn(SQLName first) {
		this.firstColumn = first;
	}

	public boolean isFirst() {
		return first;
	}

	public void setFirst(boolean first) {
		this.first = first;
	}

	public SQLName getAfterColumn() {
		return afterColumn;
	}

	public void setAfterColumn(SQLName after) {
		this.afterColumn = after;
	}

	@Override
	protected void accept0(SQLAstVisitor visitor) {
		if (visitor instanceof MySqlASTVisitor) {
			accept0((MySqlASTVisitor) visitor);
		} else {
			throw new IllegalArgumentException("not support visitor type : " + visitor.getClass().getName());
		}
	}

	public void accept0(MySqlASTVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, getColumns());

			acceptChild(visitor, firstColumn);
			acceptChild(visitor, afterColumn);
		}
		visitor.endVisit(this);
	}
}
